import LayoutContext, { ILayoutDto } from "@/app/LayoutContext";
import { Button } from "antd";
import { memo, useContext } from "react";

interface IProps {
  name: string;
}

function Test(props: IProps) {
  const contextData = useContext(LayoutContext);
  const { name } = props;

  return (
    <>
      <Button
        onClick={() => {
          contextData?.setLayoutData?.((pre: ILayoutDto) => {
            return {
              ...pre,
              num: pre.num + 1,
            } as ILayoutDto;
          });
        }}
      >
        ++
      </Button>
      {name}
      {contextData?.layoutData?.num}
    </>
  );
}
export default memo(Test);
